LoginPortlet = Class.extend({
	init: function()	{
		this.name = "LoginPortlet";
	},
	
	onBegin: function()	{
		this.registerObserver();
	},
	
	onLoginButtonClick: function()	{
		var email = this.requestForEffectiveResource('Email').val();
		var pwd = this.requestForEffectiveResource('Password').val();
		var persistent = this.requestForEffectiveResource('Persistent').is(':checked');
		if (persistent == true)	{
			persistent = 1;
		} else {
			persistent = 0;
		}
		this.onAjax('user', 'login', {email: email, pwd: pwd, persistent: persistent}, 'POST', {
			'onSuccess': function(ret)	{
				var subject = SingletonFactory.getInstance(Subject);
				subject.notifyEvent('RequestRoute', new Request('Home'));
			},
			
			'onFailure': function(msg)	{
				alert(msg);
			}
		});
	},
	
	run: function()	{
		//store the current object
		this.getPortletPlaceholder().paintCanvas(this.render());
	},
	
	onEnd: function()	{
		this.unregisterObserver();
	}
}).implement(PortletInterface).implement(RenderInterface).implement(AjaxInterface).implement(ObserverInterface);